package com.haizhi.crm.biz.dao;

import com.haizhi.crm.biz.model.ThumbDo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * Desc:点赞dao
 * Created by ch on 2018/02/29
 */
@Repository
public interface ThumbDao extends CrudRepository<ThumbDo, Long> {

    /**
     * 添加
     *
     * @param userId
     * @param entityType
     * @param entityKey
     */
    @Modifying
    @Query(value = "insert into tb_thumb(user_id, entity_type, entity_key) " +
            "values(:userId, :entityType, :entityKey)", nativeQuery = true)
    void insertThumb(@Param("userId" ) Long userId, @Param("entityType" ) String entityType, @Param("entityKey" ) String entityKey);


    /**
     * 删除
     *
     * @param userId
     * @param entityType
     * @param entityKey
     */
    @Modifying
    @Query(value = "delete from tb_thumb  where user_id=:userId and entity_type=:entityType and entity_key=:entityKey", nativeQuery = true)
    void deleteThumb(@Param("userId" ) Long userId, @Param("entityType" ) String entityType, @Param("entityKey" ) String entityKey);
}
